package com.lqm.dao;


import com.lqm.entity.home.HomeUser;
import com.lqm.entity.home.Project;
import com.lqm.entity.home.ProjectScore;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface ProjectScoreDao extends JpaRepository<ProjectScore, Integer>, PagingAndSortingRepository<ProjectScore, Integer> {


    List<ProjectScore> findAllByProject(Project project);

    List<ProjectScore> findAllByHomeUserAndProject(HomeUser homeUser,Project project);

    @Query("select avg(s.score) from ProjectScore s where s.project=:project")
    Double findAvgByProjectId(@Param("project") Project project);

    List<ProjectScore> findAllByProject(Project project,Pageable pageable);

}
